/-docs
/-editor
CodeMirrorEditor.ts
CompletionCodeMirrorEditor.ts
CssEditorType.ts
Editor.ts
EditorType.ts
HtmlEditorType.ts
JavaScriptEditorType.ts
TypeScriptEditorType.ts
x-last-PlainTextEditorType.ts
/-files
/-files-old
/-imports
/-layout
/-storage
/-tests ...
/-tests/files
/-tests/storage
TestCase.html
TestCase.ts
TestPage.css
TestPage.html
TestPage.ts
_sampleTests.ts
teapo-tests.html
teapo-tests.ts
/-typings
codemirror.d.ts
knockout.d.ts
typescriptServices.d.ts
websql.d.ts
zip.js.d.ts
TypeScriptService.ts
functions.ts
ko.ts
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.ts
x
1
module teapo.testApp {
2
3
  export function run() {
4
5
//     try {
6
7
8
      var pageElement: HTMLElement = null;
9
10
      for (var i = 0; i < document.body.childNodes.length; i++) {
11
        var e = <HTMLElement>document.body.childNodes.item(i);
12
        if (e && e.tagName && e.tagName.toLowerCase()
13
          && e.className && e.className.indexOf('teapo-page') >= 0) {
14
15
          pageElement = e;
16
          break;
17
18
        }
19
      }
20
21
22
      addEventListener(window, 'keydown', e => {
23
        if ((<any>e).keyCode === 83 /* S */) {
24
          var blob: Blob = new (<any>Blob)(['<!doctype html>\n', document.documentElement.outerHTML], { type: 'application/octet-stream' });
25
          var url = URL.createObjectURL(blob);
26
          var a = document.createElement('a');
27
          a.href = url;
28
          a.setAttribute('download', 'teapo-tests.html');
29
          try {
30
            // safer save method, supposed to work with FireFox
31
            var evt = document.createEvent("MouseEvents");
32
            (<any>evt).initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
33
            a.dispatchEvent(evt);
34
          }
35
          catch (e) {
36
            a.click();
37
          }
38
        }
39
      });
40
41
42
      var testPage = new teapo.tests.TestPage();
43
      ko.renderTemplate('TestPage', testPage, null, pageElement);
44
45
      setTimeout(() => {
46
        testPage.start();
47
      }, 10);
48
49
50
//     }
51
//     catch (initError) {
52
//       alert(initError.message + ' ' + (initError.stack ? initError.stack : initError));
53
//     }
54
  }
55
56
}
5:0